home *** CD-ROM | disk | FTP | other *** search
- Path: SOL1.GPS.CALTECH.EDU!CARL
- From: carl@SOL1.GPS.CALTECH.EDU (Carl J Lydick)
- Newsgroups: comp.os.vms,comp.sys.dec,comp.lang.c
- Subject: Re: getting correct local time in VAX C program
- Date: 31 Mar 1996 19:07:45 GMT
- Organization: HST Wide Field/Planetary Camera
- Distribution: world
- Message-ID: <4jml61$gth@gap.cco.caltech.edu>
- References: <4jec36$ff3@lastactionhero.rs.itd.umich.edu>
- Reply-To: carl@SOL1.GPS.CALTECH.EDU
- NNTP-Posting-Host: sol1.gps.caltech.edu
-
- In article <4jec36$ff3@lastactionhero.rs.itd.umich.edu>, raffel@umich.edu (David Raffel) writes:
- =
- =I'm having a problem using the c localtime function to convert a
- ="timestamp" (represented in seconds since 1/1/1970) to a date
- =and time. I'm running under VMS V5.5-2 and using VAXC V3.1.
- =
- =The problem is that the timestamp is being written out to a file
- =by a SUN which takes into account timezone information. When I
- =read the timestamp on VMS and convert it, I get the correct date,
- =but the time is off by 5 hours. I assume that this is because
- =the VAX doesn't use any timezone information and always returns
- =GMT.
- =
- =When I call time() to get the current time in seconds, the
- =time returned on VMS is different by 18000 seconds
-
- That's 5 hours, by the way.
-
- =from the
- =time returned on the SUN.
- =
- =Are there any routines available that will return the correct
- =local time, or any suggestions for how I can get the correct
- =time?
-
- #include descrip
- #define ckstat(x) if (((stat = x) & 7) != 1) SYS$EXIT(stat)
-
- main()
- { unsigned long timadr[2], stat, SYS$EXIT(), SYS$GETTIM(), SYS$ASCTIM();
- void puts();
- char buffer[33];
- $DESCRIPTOR(timbuf, buffer);
-
- ckstat(SYS$GETTIM(timadr));
- ckstat(SYS$ASCTIM(&timbuf.dsc$w_length, &timbuf, timadr, 0));
- buffer[timbuf.dsc$w_length] = '\0';
- puts(buffer);
- }
- --------------------------------------------------------------------------------
- Carl J Lydick | INTERnet: CARL@SOL1.GPS.CALTECH.EDU | NSI/HEPnet: SOL1::CARL
-
- Disclaimer: Hey, I understand VAXen and VMS. That's what I get paid for. My
- understanding of astronomy is purely at the amateur level (or below). So
- unless what I'm saying is directly related to VAX/VMS, don't hold me or my
- organization responsible for it. If it IS related to VAX/VMS, you can try to
- hold me responsible for it, but my organization had nothing to do with it.
-